home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / tabvie.zip / TABVIEW.CPP < prev    next >
C/C++ Source or Header  |  1994-04-13  |  30KB  |  1,120 lines

  1. // CTabView:
  2. // written by Gerry High
  3. // 74750,2456 CIS
  4. // for more info see the tabview.wri document
  5.  
  6. #include "stdafx.h"
  7. #include "tabview.h"
  8. #include <ctype.h>
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14.  
  15. #define BASE CView
  16. #define THIS CTabView
  17. const int TAB_TABHEIGHT = 25;
  18. const int TAB_MARGIN = 7;
  19.  
  20. #define BKPEN()pDC->SelectObject(&blackPen)
  21. #define LTPEN()pDC->SelectObject(&lightPen)
  22. #define DKPEN()pDC->SelectObject(&darkPen)
  23. #define MARGIN    7
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CTabView
  26.  
  27. IMPLEMENT_DYNCREATE(CTabView, CView)
  28.  
  29. BEGIN_MESSAGE_MAP(CTabView, CView)
  30.     //{{AFX_MSG_MAP(CTabView)
  31.     ON_WM_ERASEBKGND()
  32.     ON_WM_SIZE()
  33.     ON_WM_LBUTTONDOWN()
  34.     ON_WM_SETFOCUS()
  35.     ON_WM_MOUSEACTIVATE()
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CTabView construction/destruction
  41.  
  42. THIS::THIS()
  43. {
  44.     m_curTab = -1;
  45.     m_nTabs = 0;
  46.     m_tabHeight = TAB_TABHEIGHT;
  47.     m_lookAndFeel = LAF_MSWORD;
  48.     m_curView = NULL;
  49.     m_position = TABSONTOP;
  50.     m_lfEscapement = 0;
  51.     m_margin = TAB_MARGIN;
  52.     m_boldFont = NULL;
  53.     m_normalFont = NULL;
  54. }
  55.  
  56. THIS::~THIS()
  57. {
  58.     // free up tab info
  59.     CObject* pTab;
  60.     for(int i=0;i<m_nTabs;i++)
  61.     {
  62.         if( (pTab = m_tabArray.GetAt(0)) != NULL)
  63.         {
  64.             m_tabArray.RemoveAt(0);
  65.             delete pTab;
  66.         }
  67.     }
  68.     if(m_boldFont)
  69.         delete m_boldFont;
  70.     if(m_normalFont)
  71.         delete m_normalFont;
  72. }
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CTabView configuration helper methods
  75.  
  76. void  THIS::setLAF(eLookAndFeel LAF)
  77. {
  78.     if(LAF == m_lookAndFeel)
  79.         return;
  80.         
  81.     m_lookAndFeel = LAF;
  82.     if(IsWindowVisible()) InvalidateRect(NULL);
  83. }
  84. void THIS::setMargin(int margin)
  85. {
  86.     if(margin == m_margin)
  87.         return;
  88.         
  89.     m_margin = margin;
  90.     repositionViews();
  91.     if(IsWindowVisible()) InvalidateRect(NULL);
  92. }
  93.  
  94. void THIS::setTabHeight(int height)
  95. {
  96.     if(height == m_tabHeight)
  97.         return;
  98.         
  99.     m_tabHeight = height;
  100.     repositionViews();
  101.     if(IsWindowVisible()) InvalidateRect(NULL);
  102. }
  103.  
  104. void THIS::setTabPosition(eTabPosition position)
  105. {
  106.     int i,j;
  107.  
  108.     if(position == m_position)
  109.         return;
  110.             
  111.     switch (position)
  112.     {
  113.         case TABSONLEFT:
  114.         case TABSONLEFTBOT:
  115.         case TABSONRIGHT:
  116.         case TABSONRIGHTBOT:
  117.             m_position = position;
  118.             if(m_position == TABSONLEFT || m_position == TABSONLEFTBOT)
  119.                 m_lfEscapement = 900;
  120.             else
  121.                 m_lfEscapement = -900;
  122.             for(j=0;j<m_nTabs;j++)
  123.             {
  124.                 CTabInfo* pTab = (CTabInfo*)m_tabArray[j];
  125.                 int sLen = strlen(pTab->m_tabLabel);
  126.                 for(i=0;i<sLen;i++)
  127.                 {
  128.                     if(pTab->m_tabLabel[i] == '&' && i != (sLen -1))
  129.                     {
  130.                         memmove(&pTab->m_tabLabel[i],&pTab->m_tabLabel[i+1],sLen - i);
  131.                         break;
  132.                     }
  133.                 }
  134.             }
  135.             break;
  136.  
  137.         default:
  138.             m_position = TABSONTOP;
  139.             m_lfEscapement = 0;
  140.             for(j=0;j<m_nTabs;j++)
  141.             {
  142.                 CTabInfo* pTab = (CTabInfo*)m_tabArray[j];
  143.                 int sLen = strlen(pTab->m_tabLabel);
  144.                 for(i=0;i<sLen;i++)
  145.                 {
  146.                     if((char)(DWORD)AnsiUpper((LPSTR)MAKELP(0,pTab->m_tabLabel[i])) == pTab->m_mnemonic
  147.                          && i != (sLen -1))
  148.                     {
  149.                         memmove(&pTab->m_tabLabel[i+1],&pTab->m_tabLabel[i],sLen - i);
  150.                         pTab->m_tabLabel[i] = '&';
  151.                         break;
  152.                     }
  153.                 }
  154.             }
  155.             break;
  156.     }
  157.  
  158.     if(m_nTabs != 0)
  159.     {
  160.         createFonts();
  161.         repositionViews();
  162.         if(IsWindowVisible()) InvalidateRect(NULL);
  163.     }
  164. }
  165. void THIS::setFrameBorderOn(BOOL on)
  166. {
  167.     m_frameBorderOn = on;
  168. }
  169. void THIS::repositionViews()
  170. {
  171.     for(int i=0;i<m_nTabs;i++)
  172.     {
  173.         CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  174.         switch (m_position)
  175.         {
  176.             case TABSONLEFT:
  177.             case TABSONLEFTBOT:
  178.                 pTab->m_pView->SetWindowPos(NULL,m_margin+5+m_tabHeight,m_margin+5,
  179.                     m_width-2*(m_margin+5)-m_tabHeight,    m_height-2*(m_margin+5), SWP_NOZORDER);
  180.                 break;
  181.  
  182.             case TABSONRIGHT:
  183.             case TABSONRIGHTBOT:
  184.                 pTab->m_pView->SetWindowPos(NULL,m_margin+5,m_margin+5,
  185.                     m_width-2*(m_margin+5)-m_tabHeight,    m_height-2*(m_margin+5), SWP_NOZORDER);
  186.                 break;
  187.  
  188.             default:
  189.                 pTab->m_pView->SetWindowPos(NULL, m_margin+5,m_margin+5+m_tabHeight,
  190.                     m_width-2*(m_margin+5), m_height-2*(m_margin+5)-m_tabHeight, SWP_NOZORDER);
  191.                 break;
  192.         }
  193.     }
  194. }
  195. void THIS::createFonts()
  196. {
  197.     if(m_normalFont)
  198.         delete m_normalFont;
  199.     if(m_boldFont)
  200.         delete m_boldFont;
  201.         
  202.     // generate fonts    
  203.     LOGFONT fontRec;
  204.     
  205.     memset(&fontRec,0,sizeof(LOGFONT));
  206.     fontRec.lfHeight = -13;
  207.     fontRec.lfWeight = FW_NORMAL;
  208.     fontRec.lfEscapement = m_lfEscapement;
  209.     lstrcpy(fontRec.lfFaceName,"Arial");
  210.     
  211.     m_normalFont = new CFont;
  212.     m_normalFont->CreateFontIndirect(&fontRec);
  213.     
  214.     fontRec.lfWeight = FW_BOLD;
  215.     m_boldFont = new CFont;
  216.     m_boldFont->CreateFontIndirect(&fontRec);
  217. }
  218.  
  219.  
  220. /////////////////////////////////////////////////////////////////////////////
  221. // CTabView message handlers
  222.  
  223. BOOL THIS::OnEraseBkgnd(CDC* pDC)
  224. {
  225.     CBrush backBrush(GetSysColor(COLOR_BTNFACE));
  226.     CBrush* pOldBrush = pDC->SelectObject(&backBrush);
  227.     
  228.     CRect rect;
  229.     pDC->GetClipBox(&rect);    //erase the area needed
  230.     pDC->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATCOPY);
  231.     pDC->SelectObject(pOldBrush);
  232.     return TRUE;
  233. }
  234.  
  235. void THIS::OnSize(UINT nType, int cx, int cy)
  236. {
  237.     CView::OnSize(nType, cx, cy);
  238.     m_width = cx;
  239.     m_height = cy;
  240.     
  241.     for(int i=0;i<m_nTabs;i++)
  242.     {
  243.         CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  244.         switch (m_position)
  245.         {
  246.             case TABSONLEFT:
  247.             case TABSONLEFTBOT:
  248.             case TABSONRIGHT:
  249.             case TABSONRIGHTBOT:
  250.                 pTab->m_pView->SetWindowPos(NULL,0,0,cx-2*(m_margin+5)-m_tabHeight,cy-2*(m_margin+5),
  251.                     SWP_NOMOVE|SWP_NOZORDER);
  252.                 break;
  253.  
  254.             default:
  255.                 pTab->m_pView->SetWindowPos(NULL,0,0,cx-2*(m_margin+5),cy-2*(m_margin+5)-m_tabHeight,
  256.                     SWP_NOMOVE|SWP_NOZORDER);
  257.                 break;
  258.         }
  259.     }
  260. }
  261. void THIS::OnLButtonDown(UINT nFlags, CPoint point)
  262. {
  263.     switch (m_position)
  264.     {
  265.         case TABSONLEFT:
  266.         case TABSONLEFTBOT:
  267.         case TABSONRIGHT:
  268.         case TABSONRIGHTBOT:
  269.             if ( switchVerticalTab(point) )
  270.                 return;
  271.  
  272.         default:
  273.             if ( switchTopTab(point) )
  274.                 return;
  275.     }
  276.     GetParentFrame()->SetActiveView(m_curView);
  277. }
  278.  
  279. BOOL CTabView::switchVerticalTab(CPoint point)
  280. {
  281.     CRect rect;
  282.     int x = (m_position == TABSONLEFT || m_position == TABSONLEFTBOT) ? m_margin : 
  283.         (m_width - m_margin - m_tabHeight);
  284.     int y = (m_position == TABSONLEFT || m_position == TABSONRIGHT) ? m_margin:(m_height - m_margin);
  285.  
  286.     rect.left = x;
  287.     rect.right = rect.left + m_tabHeight;
  288.     
  289.     for(int i = 0; i < m_nTabs; i++)
  290.     {
  291.         CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  292.         if(m_position == TABSONLEFT || m_position == TABSONRIGHT)
  293.         {
  294.             rect.top     = y;
  295.             rect.bottom = y + pTab->m_tabWidth;
  296.         }
  297.         else
  298.         {
  299.             rect.bottom = y;
  300.             rect.top = rect.bottom - pTab->m_tabWidth;
  301.         }
  302.         if(rect.PtInRect(point) && pTab->m_active)
  303.         {
  304.             switchTab(i);
  305.             return TRUE;
  306.         }
  307.         if(m_position == TABSONLEFT || m_position == TABSONRIGHT)
  308.             y += pTab->m_tabWidth;
  309.         else
  310.             y -= pTab->m_tabWidth;
  311.     }
  312.     return(FALSE);
  313. }
  314. BOOL CTabView::switchTopTab(CPoint point)
  315. {
  316.     CRect rect;
  317.     int x = m_margin, y = m_margin;
  318.  
  319.     rect.top = y;
  320.     rect.bottom = y + m_tabHeight;
  321.  
  322.     for(int i = 0; i < m_nTabs; i++)
  323.     {
  324.         CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  325.         rect.left = x;
  326.         rect.right = rect.left + pTab->m_tabWidth;
  327.         if(rect.PtInRect(point) && pTab->m_active)
  328.         {
  329.             switchTab(i);
  330.             return TRUE;
  331.         }
  332.         x += pTab->m_tabWidth;
  333.     }
  334.     return(FALSE);
  335. }
  336. void THIS::OnInitialUpdate()
  337. {
  338.     BASE::OnInitialUpdate();
  339.  
  340.     createFonts();
  341.     
  342.     CFrameWnd* pFrame = GetParentFrame();
  343.     pFrame->RecalcLayout();
  344.     m_curTab = 0;
  345.     
  346.     if(m_nTabs)
  347.     {
  348.         CTabInfo* pTab = (CTabInfo*)m_tabArray[0];
  349.         m_curView = pTab->m_pView;
  350.         m_curView->ShowWindow(SW_SHOW);
  351.         pFrame->SetActiveView(m_curView);
  352.     }
  353. }
  354. CView* THIS::addTabView(
  355.     CRuntimeClass* viewClass,
  356.     CDocument* document,
  357.     char* tabLabel,
  358.     BOOL border,
  359.     BOOL show,
  360.     int tabWidth
  361.     )
  362. {
  363.     // Setup defaults
  364.  
  365.     if(!tabLabel)
  366.         return NULL;
  367.  
  368.     CTabInfo* pTab = new CTabInfo;
  369.     if(!pTab)
  370.         return NULL;
  371.         
  372.     m_curTab++;
  373.     pTab->m_pView = createTabView(viewClass,document,this,border,show);
  374.     if(!pTab->m_pView)
  375.     {
  376.         delete pTab;
  377.         m_curTab--;
  378.         return NULL;
  379.     }
  380.     pTab->m_tabWidth = tabWidth;
  381.     int sLen = strlen(tabLabel);
  382.     pTab->m_tabLabel = (char *)new char[sLen + 1 ];
  383.     strcpy(pTab->m_tabLabel,tabLabel);
  384.     for(int i=0;i<sLen;i++)
  385.     {
  386.         if(tabLabel[i] == '&' && i != (sLen -1))
  387.         {
  388.             pTab->m_mnemonic = (char)(DWORD)AnsiUpper((LPSTR)MAKELP(0,tabLabel[i+1]));
  389.             if(m_position == TABSONLEFT ||
  390.                m_position == TABSONLEFTBOT)
  391.                 memmove(&tabLabel[i],&tabLabel[i+1],sLen - i-1);
  392.             break;
  393.         }
  394.     }
  395.     
  396.     m_tabArray.Add(pTab);
  397.     m_nTabs++;
  398.  
  399.     return pTab->m_pView;
  400. }
  401. CView* THIS::createTabView(
  402.     CRuntimeClass* pViewClass,
  403.     CDocument* pDoc,
  404.     CWnd*    parentWnd,
  405.     BOOL border,
  406.     BOOL show
  407.     )
  408. {
  409.     CRect viewRect;
  410.  
  411.     switch (m_position)
  412.     {
  413.         case TABSONLEFT:
  414.         case TABSONLEFTBOT:
  415.             viewRect.SetRect(m_margin+5+m_tabHeight,m_margin+5,m_width-(m_margin+5),m_height-(m_margin+5));
  416.             break;
  417.  
  418.         case TABSONRIGHT:
  419.         case TABSONRIGHTBOT:
  420.             viewRect.SetRect(m_margin+5,m_margin+5,m_width-(m_margin+5),m_height-(m_margin+5));
  421.             break;
  422.  
  423.         default:
  424.             viewRect.SetRect(m_margin+5,m_margin+5+m_tabHeight,m_width-(m_margin+5),m_height-(m_margin+5));
  425.             break;
  426.     }
  427.  
  428.     CView* pView = (CView*)pViewClass->CreateObject();
  429.     ASSERT(pView != NULL);
  430.     
  431.       CCreateContext context;
  432.        context.m_pNewViewClass        = pViewClass;
  433.        context.m_pCurrentDoc        = pDoc;
  434.        context.m_pNewDocTemplate    = NULL;
  435.        context.m_pLastView            = NULL;
  436.        context.m_pCurrentFrame        = GetParentFrame();
  437.     if (!pView->Create(NULL, NULL, WS_CHILD|(show ? WS_VISIBLE:0)|
  438.         (border ? WS_BORDER : 0),viewRect,
  439.         this, AFX_IDW_PANE_FIRST+1+m_curTab, &context))
  440.     {
  441.             TRACE0("Warning: couldn't create view for frame\n");
  442.             return NULL;
  443.     }
  444.  
  445.     return pView;
  446. }
  447. void THIS::switchTab(int viewIndex)
  448. {
  449.     CTabInfo* pTab = (CTabInfo*)m_tabArray[viewIndex];
  450.     if(viewIndex < 0 || viewIndex >= m_nTabs)
  451.         return;
  452.  
  453.     if(m_curView != pTab->m_pView)
  454.     {
  455.         pTab->m_pView->ShowWindow(SW_SHOW);
  456.         m_curView->ShowWindow(SW_HIDE);
  457.         m_curView = pTab->m_pView;
  458.         m_curTab = viewIndex;
  459.         InvalidateRect(NULL);
  460.     }
  461.     GetParentFrame()->SetActiveView(m_curView);
  462. }
  463. void THIS::enableView(int viewIndex, BOOL bEnable)
  464. {
  465.     CTabInfo* pTab = (CTabInfo*)m_tabArray[viewIndex];
  466.     if(viewIndex < 0 || viewIndex >= m_nTabs)
  467.         return;
  468.  
  469. //can't disable current view
  470.     if(m_curView != pTab->m_pView && bEnable != pTab->m_active)
  471.     {
  472.         pTab->m_active = bEnable;
  473.         if(IsWindowVisible()) InvalidateRect(NULL);
  474.     }
  475. }
  476. BOOL THIS::doSysCommand(UINT nID,LONG lParam)
  477. {
  478.     WPARAM wCmdType = nID & 0xFFF0;
  479.     WORD dummy = HIWORD(lParam);
  480.     char mnemonic = (char)(DWORD)AnsiUpper((LPSTR)MAKELP(0,(char)LOWORD(lParam)));
  481.     switch(wCmdType)
  482.     {
  483.         case SC_KEYMENU:
  484.             if(dummy != 0)
  485.                 break;
  486.             for(int i = 0; i < m_nTabs; i++)
  487.             {
  488.                 CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  489.                 if(mnemonic == pTab->m_mnemonic && pTab->m_active)
  490.                 {
  491.                     switchTab(i);
  492.                     return 1;
  493.                 }
  494.             }
  495.             break;
  496.     }
  497.     return 0;
  498. }
  499. /////////////////////////////////////////////////////////////////////////////
  500. // CTabView drawing
  501.  
  502. void THIS::OnDraw(CDC* pDC)
  503. {
  504.     CFont* oldFont = pDC->SelectObject(m_boldFont);
  505.     int oldMode = pDC->SetBkMode(TRANSPARENT);
  506.     
  507.     CPen blackPen(PS_SOLID,0,GetSysColor(COLOR_WINDOWFRAME));
  508.     CPen darkPen(PS_SOLID,0,GetSysColor(COLOR_BTNSHADOW));
  509.     CPen lightPen(PS_SOLID,0,GetSysColor(COLOR_BTNHIGHLIGHT));
  510.     CPen* pOldPen = pDC->SelectObject(&darkPen);
  511.  
  512.     if(m_lookAndFeel == LAF_CHICAGO && m_position == TABSONLEFT)
  513.     {
  514.         TRACE0("Warning: left tabs not supported for LAF = CHICAGO");
  515.         m_lookAndFeel = LAF_MSWORD;
  516.     }
  517.  
  518.     if(m_lookAndFeel == LAF_CHICAGO)
  519.     {    
  520.         drawChicagoTabs(pDC, blackPen, darkPen, lightPen, pOldPen);
  521.     }
  522.     else // MS WORD STYLE LOOK--compliments of David Hollifield
  523.     {
  524.         drawMSWordTabs(pDC, blackPen, darkPen, lightPen, pOldPen);
  525.     }
  526.  
  527.     pDC->SelectObject(pOldPen);
  528.     pDC->SetBkMode(oldMode);
  529.     pDC->SelectObject(oldFont);
  530. }
  531. void THIS::drawChicagoTabs(CDC *pDC, CPen& blackPen, CPen& darkPen, CPen& lightPen, CPen *pOldPen)
  532. {   
  533.     COLORREF oldTextColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
  534.     int x, y, width, height;
  535.     CRect rect;
  536.     pDC->GetClipBox(&rect);
  537.  
  538.     x = m_margin;
  539.     y = m_margin + m_tabHeight;
  540.     width = m_width - 2 * m_margin;
  541.     height = m_height - 2 * m_margin;
  542.  
  543.     //
  544.     //draw 3 outer lines of bounding rect
  545.     //    
  546.     DKPEN();
  547.      pDC->MoveTo(x,y);
  548.      pDC->LineTo(x,y+height-1-m_tabHeight);
  549.     pDC->LineTo(x+width-1,y+height-1-m_tabHeight);
  550.     pDC->LineTo(x+width-1,y);
  551.  
  552.     BKPEN();
  553.     pDC->MoveTo(x,y+height-m_tabHeight);
  554.      pDC->LineTo(x+width,y+height-m_tabHeight);
  555.      pDC->LineTo(x+width,y);
  556.  
  557.     LTPEN();     
  558.     pDC->MoveTo(x+1,y);
  559.     pDC->LineTo(x+1,y+height-2-m_tabHeight);
  560.  
  561.     //
  562.     // now draw each tab
  563.     //
  564.     x = m_margin;
  565.     y = m_margin;
  566.     for(int i=0;i<m_nTabs;i++)
  567.     {
  568.         CTabInfo* pTab = (CTabInfo*)m_tabArray[i];
  569.         if(i == m_curTab)
  570.         {
  571.             DKPEN();
  572.              pDC->MoveTo(x,y+1);
  573.              pDC->LineTo(x,y+3+m_tabHeight-3);
  574.  
  575.             LTPEN();
  576.              pDC->MoveTo(x+1,y+1);
  577.              pDC->LineTo(x+1,y+3+m_tabHeight-3);
  578.         
  579.             pDC->MoveTo(x+2,y);    //1 pixel spot
  580.              pDC->LineTo(x+3,y+1);
  581.         
  582.              pDC->MoveTo(x+3,y-1);
  583.             pDC->LineTo(x+pTab->m_tabWidth-2,y-1);
  584.  
  585.             DKPEN();
  586.              pDC->MoveTo(x+3,y-2);
  587.             pDC->LineTo(x+pTab->m_tabWidth-2,y-2);
  588.             pDC->LineTo(x+pTab->m_tabWidth-2,y+m_tabHeight);
  589.         
  590.              BKPEN();
  591.             pDC->MoveTo(x+pTab->m_tabWidth-1,y+1);
  592.             pDC->LineTo(x+pTab->m_tabWidth-1,y+m_tabHeight);
  593. //              
  594.             LTPEN();
  595.             if(i != 0)
  596.             {
  597.                  pDC->MoveTo(x-1,y+3+m_tabHeight-4);
  598.                  pDC->LineTo(m_margin+1,y+3+m_tabHeight-4);
  599.             }
  600.             pDC->MoveTo(x+pTab->m_tabWidth,y+3+m_tabHeight-4);
  601.             pDC->LineTo(m_width-m_margin-2,y+3+m_tabHeight-4);
  602.  
  603.              DKPEN();
  604.              pDC->MoveTo(x+pTab->m_tabWidth,y+3+m_tabHeight-5);
  605.             pDC->LineTo(m_width-m_margin-2,y+3+m_tabHeight-5);
  606.             pDC->SelectObject(m_boldFont);
  607.         }
  608.         else
  609.         {
  610.             DKPEN();
  611.              pDC->MoveTo(x,y+3);
  612.             pDC->LineTo(x,y+3+m_tabHeight-3);
  613.  
  614.             LTPEN();
  615.              pDC->MoveTo(x+1,y+3);
  616.              pDC->LineTo(x+1,y+3+m_tabHeight-3);
  617.         
  618.              pDC->MoveTo(x+2,y+2);    //1 pixel spot
  619.             pDC->LineTo(x+3,y+3);
  620.         
  621.             pDC->MoveTo(x+3,y+1);
  622.              pDC->LineTo(x+pTab->m_tabWidth-2,y+1);
  623.         
  624.             DKPEN();
  625.             pDC->MoveTo(x+3,y);
  626.              pDC->LineTo(x+pTab->m_tabWidth-2,y);
  627.              pDC->LineTo(x+pTab->m_tabWidth-2,y+m_tabHeight);
  628.         
  629.              BKPEN();
  630.             pDC->MoveTo(x+pTab->m_tabWidth-1,y+3);
  631.             pDC->LineTo(x+pTab->m_tabWidth-1,y+m_tabHeight);
  632.             pDC->SelectObject(m_normalFont);
  633.         }
  634.  
  635.         CRect rect(x,y,x+pTab->m_tabWidth,y+m_tabHeight);
  636.         pDC->SetTextColor(GetSysColor(pTab->m_active ? COLOR_BTNTEXT:COLOR_GRAYTEXT));
  637.         pDC->DrawText(pTab->m_tabLabel,lstrlen(pTab->m_tabLabel),&rect,
  638.                 DT_CENTER|DT_VCENTER|DT_SINGLELINE);
  639.          x += pTab->m_tabWidth;
  640.         
  641.     }
  642.  
  643.     pDC->SetTextColor(oldTextColor);
  644. }
  645. void THIS::drawMSWordTabs(CDC *pDC, CPen& blackPen, CPen& darkPen, CPen& lightPen, CPen *pOldPen)
  646. {
  647.     switch (m_position)
  648.     {
  649.         case TABSONLEFT:
  650.         case TABSONLEFTBOT:
  651.             drawMSWordLeftTabs(pDC, blackPen, darkPen, lightPen, pOldPen);
  652.             break;
  653.  
  654.         case TABSONRIGHT:
  655.         case TABSONRIGHTBOT:
  656.             drawMSWordRightTabs(pDC, blackPen, darkPen, lightPen, pOldPen);
  657.             break;
  658.  
  659.         default:
  660.             drawMSWordTopTabs(pDC, blackPen, darkPen, lightPen, pOldPen);
  661.             break;
  662.     }
  663. }
  664. void THIS::drawMSWordTopTabs(CDC *pDC, CPen& blackPen, CPen& darkPen, CPen& lightPen, CPen *pOldPen)
  665. {
  666.     COLORREF oldTextColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
  667.     int x, y, width, height;
  668.     CRect rect;
  669.     pDC->GetClipBox(&rect);
  670.  
  671.     x = m_margin;
  672.     y = m_margin + m_tabHeight;
  673.     width = m_width - 2 * m_margin;
  674.     height = m_height - 2 * m_margin;
  675.  
  676.     // draw 3 outer lines of bounding rect
  677.     //
  678.     BKPEN();
  679.     pDC->MoveTo(x                , y);
  680.     pDC->LineTo(x                , y + height - m_tabHeight);
  681.     pDC->LineTo(x + width        , y + height - m_tabHeight);
  682.     pDC->LineTo(x + width        , y - 1);
  683.  
  684.     LTPEN();
  685.     pDC->MoveTo(x + 1            , y);
  686.     pDC->LineTo(x + 1            , y + height - m_tabHeight);
  687.     pDC->MoveTo(x + 2            , y);
  688.     pDC->LineTo(x + 2            , y + height - 1 - m_tabHeight);
  689.  
  690.     DKPEN();
  691.     pDC->MoveTo(x + 2            , y + height - 1 - m_tabHeight);
  692.     pDC->LineTo(x + width - 1    , y + height - 1 - m_tabHeight);
  693.     pDC->LineTo(x + width - 1    , y);
  694.     pDC->MoveTo(x + 3            , y + height - 2 - m_tabHeight);
  695.     pDC->LineTo(x + width - 2    , y + height - 2 - m_tabHeight);
  696.     pDC->LineTo(x + width - 2    , y + 1);
  697.  
  698.     // now draw each tab
  699.     //
  700.     x = m_margin;
  701.     y = m_margin;
  702.  
  703.     for (int i = 0; i < m_nTabs; i++)
  704.     {
  705.         CTabInfo *pTab = (CTabInfo *) m_tabArray[i];
  706.  
  707.         if (i == m_curTab)
  708.         {
  709.             // Outline
  710.             BKPEN();
  711.             pDC->MoveTo(m_margin                    , y + m_tabHeight);
  712.             pDC->LineTo(x                        , y + m_tabHeight);    // 1
  713.             pDC->LineTo(x                        , y + 4);            // 2
  714.             pDC->LineTo(x + 4                    , y);                // 3
  715.             pDC->LineTo(x + pTab->m_tabWidth - 4, y);                // 4
  716.             pDC->LineTo(x + pTab->m_tabWidth    , y + 4);            // 5
  717.             pDC->LineTo(x + pTab->m_tabWidth    , y + m_tabHeight);    // 6
  718.             pDC->LineTo(m_margin + width        , y + m_tabHeight);    // 7
  719.  
  720.             // Hilite
  721.             for (int j = 0; j < 2; j++)
  722.             {
  723.                 LTPEN();
  724.                 pDC->MoveTo(m_margin + 1                , y + m_tabHeight + 1 + j);
  725.                 pDC->LineTo(x + 1 + j                , y + m_tabHeight + 1 + j);    // 1
  726.                 pDC->LineTo(x + 1 + j                , y + 4 + j);                // 2
  727.                 pDC->LineTo(x + 4 + j                , y + 1 + j);                // 3
  728.                 pDC->LineTo(x + pTab->m_tabWidth - 3, y + 1 + j);                // 4
  729.                 
  730.                 pDC->MoveTo(x + pTab->m_tabWidth - 2, y + m_tabHeight + 1 + j);    
  731.                 pDC->LineTo(m_margin + width - j    , y + m_tabHeight + 1 + j);    // 7
  732.         
  733.                 if (j)
  734.                 {
  735.                     pDC->MoveTo(x + 1 + j, y + 4 + j - 1);                // fill corner gap
  736.                     pDC->LineTo(x + 4 + j, y + 1 + j - 1);                //
  737.                 }
  738.  
  739.                 // Shadow
  740.                 DKPEN();
  741.                 if(j)
  742.                 {
  743.                     pDC->MoveTo(x + pTab->m_tabWidth - 4, y + 2);
  744.                     pDC->LineTo(x + pTab->m_tabWidth - 1, y + 5);
  745.                 }
  746.  
  747.                 pDC->MoveTo(x + pTab->m_tabWidth - 3 - j, y + 2 + j);
  748.                 pDC->LineTo(x + pTab->m_tabWidth - 1 - j, y + 4 + j);                // 5
  749.                 pDC->LineTo(x + pTab->m_tabWidth - 1 - j, y + m_tabHeight + 2 + j);    // 6
  750.             }
  751.             
  752.             // Font
  753.             pDC->SelectObject(m_boldFont);
  754.         }
  755.         else
  756.         {
  757.             // Outline
  758.             BKPEN();
  759.             pDC->MoveTo(x                        , y + m_tabHeight);
  760.             pDC->LineTo(x                        , y + 4);            // 1
  761.             pDC->LineTo(x + 4                    , y);                // 2
  762.             pDC->LineTo(x + pTab->m_tabWidth - 4, y);                // 3
  763.             pDC->LineTo(x + pTab->m_tabWidth    , y + 4);            // 4
  764.             pDC->LineTo(x + pTab->m_tabWidth    , y + m_tabHeight);    // 5
  765.         
  766.             // Hilite
  767.             LTPEN();
  768.             pDC->MoveTo(x + 1                    , y + m_tabHeight - 1);
  769.             pDC->LineTo(x + 1                    , y + 4);            // 1
  770.             pDC->LineTo(x + 4                    , y + 1);            // 2
  771.             pDC->LineTo(x + pTab->m_tabWidth - 3, y + 1);            // 3
  772.     
  773.             // Shadow
  774.             DKPEN();
  775.             pDC->MoveTo(x + pTab->m_tabWidth - 3, y + 2);
  776.             pDC->LineTo(x + pTab->m_tabWidth - 1, y + 4);            // 4
  777.             pDC->LineTo(x + pTab->m_tabWidth - 1, y + m_tabHeight);    // 5
  778.             
  779.             // Font
  780.             pDC->SelectObject(m_normalFont);
  781.         }
  782.  
  783.         pDC->SetTextColor(GetSysColor(pTab->m_active ? COLOR_BTNTEXT:COLOR_GRAYTEXT));
  784.         CRect rect(x, y, x + pTab->m_tabWidth, y + m_tabHeight);
  785.         pDC->DrawText(pTab->m_tabLabel, lstrlen(pTab->m_tabLabel), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  786.         
  787.         x += pTab->m_tabWidth;
  788.     }
  789.     pDC->SetTextColor(oldTextColor);
  790. }
  791. void THIS::drawMSWordLeftTabs(CDC *pDC, CPen& blackPen, CPen& darkPen, CPen& lightPen, CPen *pOldPen)
  792. {
  793.     COLORREF oldTextColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
  794.     int x, y, width, height;
  795.     CRect rect;
  796.     pDC->GetClipBox(&rect);
  797.  
  798.     width = m_width - 2 * m_margin;
  799.     height = m_height - 2 * m_margin;
  800.  
  801.     x = m_margin;
  802.     y = m_margin + height;
  803.     if (m_frameBorderOn)
  804.     {
  805.         // draw 3 outer lines of bounding rect
  806.         //
  807.         BKPEN();
  808.         pDC->MoveTo(x + m_tabHeight                , y);
  809.         pDC->LineTo(x + width                    , y);
  810.         pDC->LineTo(x + width                    , y - height);
  811.         pDC->LineTo(x + m_tabHeight-1            , y - height);
  812.  
  813.         DKPEN();
  814.         pDC->MoveTo(x + m_tabHeight                , y - 1);
  815.         pDC->LineTo(x + width                    , y - 1);
  816.         pDC->MoveTo(x + m_tabHeight                , y - 2);
  817.         pDC->LineTo(x + width - 1                , y - 2);
  818.  
  819.         pDC->MoveTo(x + width - 1                , y - 1);
  820.         pDC->LineTo(x + width - 1                , y - height);
  821.         pDC->MoveTo(x + width - 2                , y - 1);
  822.         pDC->LineTo(x + width - 2                , y - height + 1);
  823.  
  824.         LTPEN();
  825.         pDC->MoveTo(x + width - 2                , y - height + 1);
  826.         pDC->LineTo(x + m_tabHeight + 1            , y - height + 1);
  827.         pDC->MoveTo(x + width - 3                , y - height + 2);
  828.         pDC->LineTo(x + m_tabHeight + 2            , y - height + 2);
  829.     }
  830.  
  831.     if(m_position == TABSONLEFT)
  832.     {
  833.         y = m_margin;
  834.     }
  835.     // now draw each tab
  836.     //
  837.     for (int i = 0; i < m_nTabs; i++)
  838.     {
  839.         CTabInfo *pTab = (CTabInfo *) m_tabArray[i];
  840.         if(m_position == TABSONLEFT && i == 0)
  841.         {
  842.             y += pTab->m_tabWidth;
  843.         }
  844.  
  845.         if (i == m_curTab)
  846.         {
  847.             // Outline
  848.             BKPEN();
  849.             pDC->MoveTo(x + m_tabHeight            , m_margin + height);
  850.             pDC->LineTo(x + m_tabHeight            , y);                        // 1
  851.             pDC->LineTo(x + 4                    , y);                        // 2
  852.             pDC->LineTo(x                        , y - 4);                    // 3
  853.             pDC->LineTo(x                        , y - pTab->m_tabWidth + 4);// 4
  854.             pDC->LineTo(x + 4                    , y - pTab->m_tabWidth);    // 5
  855.             pDC->LineTo(x + m_tabHeight            , y - pTab->m_tabWidth);    // 6
  856.             pDC->LineTo(x + m_tabHeight             , m_margin);                // 7
  857.  
  858.             // Hilite
  859.             for (int j = 0; j < 2; j++)
  860.             {
  861.                 LTPEN();
  862.                 pDC->MoveTo(x + m_tabHeight + 1 + j    , m_margin + height - j - 1);
  863.                 pDC->LineTo(x + m_tabHeight + 1 + j    , y - j - 1);                // 1
  864.                 DKPEN();
  865.                 pDC->LineTo(x + 4 + j                , y - j - 1);                // 2
  866.                 pDC->LineTo(x + 1 + j                , y - j - 4);                // 3
  867.                 if(j)
  868.                 {
  869.                     pDC->MoveTo(x + 4, y - 2);
  870.                     pDC->LineTo(x + 1, y - 5);
  871.                     pDC->MoveTo(x + 2, y - 5);
  872.                 }
  873.                 LTPEN();
  874.                 pDC->LineTo(x + 1 + j                , y - pTab->m_tabWidth + 3);// 4
  875.                 
  876.                 pDC->MoveTo(x + m_tabHeight + 1 + j    , y - pTab->m_tabWidth +1 + j);
  877.                 pDC->LineTo(x + m_tabHeight + 1 + j    , m_margin + j);            // 7
  878.         
  879.                 if (j)
  880.                 {
  881.                     pDC->MoveTo(x + 1        , y - pTab->m_tabWidth + 5);        // fill corner gap
  882.                     pDC->LineTo(x + 5        , y - pTab->m_tabWidth + 1);        //
  883.                 }
  884.  
  885.                 pDC->MoveTo(x + 1 + j,y - pTab->m_tabWidth + 4 + j);
  886.                 pDC->LineTo(x + 4 + j,y - pTab->m_tabWidth + 1 + j);                    // 5
  887.                 pDC->LineTo(x + m_tabHeight + 2 + j, y - pTab->m_tabWidth + 1 + j);    // 6
  888.             }
  889.             
  890.             // Font
  891.             pDC->SelectObject(m_boldFont);
  892.         }
  893.         else
  894.         {
  895.             // Outline
  896.             BKPEN();
  897.             pDC->MoveTo(x + m_tabHeight            , y);
  898.             pDC->LineTo(x + 4                     , y);                            // 1
  899.             pDC->LineTo(x                        , y - 4);                        // 2
  900.             pDC->LineTo(x                        , y - pTab->m_tabWidth + 4);    // 3
  901.             pDC->LineTo(x + 4                    , y - pTab->m_tabWidth);        // 4
  902.             pDC->LineTo(x + m_tabHeight            , y - pTab->m_tabWidth);        // 5
  903.         
  904.             // Hilite
  905.             DKPEN();
  906.             pDC->MoveTo(x + m_tabHeight    - 1        , y - 1);
  907.             pDC->LineTo(x + 4                    , y - 1);                        // 1
  908.             pDC->LineTo(x + 1                    , y - 4);                        // 2
  909.             LTPEN();
  910.             pDC->LineTo(x + 1                    , y - pTab->m_tabWidth + 3);      // 3
  911.     
  912.             // Shadow
  913.             pDC->MoveTo(x + 2                    , y - pTab->m_tabWidth + 3);
  914.             pDC->LineTo(x + 4                    , y - pTab->m_tabWidth + 1);     // 4
  915.             pDC->LineTo(x  + m_tabHeight        , y - pTab->m_tabWidth + 1);    // 5
  916.             
  917.             // Font
  918.             pDC->SelectObject(m_normalFont);
  919.         }
  920.  
  921.         // DrawText inside clipping rect doesn't seem to work for vertical orientation.
  922.         // TextOut takes the (x,y) coordinates given, and rotates the string about that point.
  923.         // So for our 90 degree rotation, (x,y) becomes the bottom left.
  924.         CSize size = pDC->GetTextExtent(pTab->m_tabLabel, strlen(pTab->m_tabLabel));
  925.         int left = x + (m_tabHeight-size.cy)/2 + 1;
  926.         int bottom  = y - (pTab->m_tabWidth - size.cx)/2;
  927.         int oldMode = pDC->SetBkMode(TRANSPARENT);
  928.  
  929.         pDC->SetTextColor(GetSysColor(pTab->m_active ? COLOR_BTNTEXT:COLOR_GRAYTEXT));
  930.         pDC->TextOut(left, bottom, pTab->m_tabLabel, strlen(pTab->m_tabLabel));
  931.         pDC->SetBkMode(oldMode);
  932.  
  933.         if(m_position == TABSONLEFT)
  934.             y += pTab->m_tabWidth;
  935.         else
  936.             y -= pTab->m_tabWidth;
  937.     }
  938.     pDC->SetTextColor(oldTextColor);
  939. }
  940. void THIS::drawMSWordRightTabs(CDC *pDC, CPen& blackPen, CPen& darkPen, CPen& lightPen, CPen *pOldPen)
  941. {
  942.     COLORREF oldTextColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
  943.     int x, y, width, height;
  944.     CRect rect;
  945.     pDC->GetClipBox(&rect);
  946.  
  947.     width = m_width - 2 * m_margin;
  948.     height = m_height - 2 * m_margin;
  949.  
  950.     x = m_margin + width;
  951.     y = m_margin + height;
  952.     if (m_frameBorderOn)
  953.     {
  954.         // draw 3 outer lines of bounding rect
  955.         //
  956.         BKPEN();
  957.         pDC->MoveTo(x - m_tabHeight                , y);
  958.         pDC->LineTo(x - width                    , y);
  959.         pDC->LineTo(x - width                     , y - height);
  960.         pDC->LineTo(x - m_tabHeight - 1            , y - height);
  961.  
  962.         DKPEN();
  963.         pDC->MoveTo(x - m_tabHeight                , y - 1);
  964.         pDC->LineTo(x - width                    , y - 1);
  965.         pDC->MoveTo(x - m_tabHeight                , y - 2);
  966.         pDC->LineTo(x - width + 1                , y - 2);
  967.  
  968.         pDC->MoveTo(x - width + 1                , y);
  969.         pDC->LineTo(x - width + 1                , y - height);
  970.         pDC->MoveTo(x - width + 2                , y);
  971.         pDC->LineTo(x - width + 2                , y - height + 1);
  972.  
  973.         LTPEN();
  974.         pDC->MoveTo(x - width + 1                , y - height + 1);
  975.         pDC->LineTo(x - m_tabHeight - 2            , y - height + 1);
  976.         pDC->MoveTo(x - width + 1                , y - height + 2);
  977.         pDC->LineTo(x - m_tabHeight - 3            , y - height + 2);
  978.     }
  979.  
  980.     if(m_position == TABSONRIGHT)
  981.     {
  982.         y = m_margin;
  983.     }
  984.     x = m_margin + width - m_tabHeight;
  985.     // now draw each tab
  986.     //
  987.     for (int i = 0; i < m_nTabs; i++)
  988.     {
  989.         CTabInfo *pTab = (CTabInfo *) m_tabArray[i];
  990.         if(m_position == TABSONRIGHT && i == 0)
  991.         {
  992.             y += pTab->m_tabWidth;
  993.         }
  994.  
  995.         if (i == m_curTab)
  996.         {
  997.             // Outline
  998.             BKPEN();
  999.             pDC->MoveTo(x                          , m_margin + height);
  1000.             pDC->LineTo(x                         , y);                        // 1
  1001.             pDC->LineTo(x + m_tabHeight - 4        , y);                        // 2
  1002.             pDC->LineTo(x + m_tabHeight            , y - 4);                    // 3
  1003.             pDC->LineTo(x + m_tabHeight            , y - pTab->m_tabWidth + 4);// 4
  1004.             pDC->LineTo(x + m_tabHeight - 4        , y - pTab->m_tabWidth);    // 5
  1005.             pDC->LineTo(x                         , y - pTab->m_tabWidth);    // 6
  1006.             pDC->LineTo(x                          , m_margin);                // 7
  1007.  
  1008.  
  1009.             // Hilite
  1010.             for (int j = 0; j < 2; j++)
  1011.             {
  1012.                 LTPEN();
  1013.                 pDC->MoveTo(x - 1 - j                , m_margin + height - j - 1);
  1014.                 pDC->LineTo(x - 1 - j                , y - j - 1);                // 1
  1015.                 DKPEN();
  1016.                 pDC->LineTo(x + m_tabHeight - 4 - j    , y - j - 1);                // 2
  1017.                 pDC->LineTo(x + m_tabHeight - 1 - j    , y - 4 - j);                // 3
  1018.                 LTPEN();
  1019.                 pDC->LineTo(x + m_tabHeight - 1 - j    , y - pTab->m_tabWidth + 3);// 4
  1020.                 
  1021.                 pDC->MoveTo(x - 1 - j                , y - pTab->m_tabWidth +1 + j);
  1022.                 pDC->LineTo(x - 1 - j                , m_margin + j);            // 7
  1023.         
  1024.                 if (j)
  1025.                 {
  1026.                     pDC->MoveTo(x + m_tabHeight - 3 - j    , y - 1 - j);                // fill corner gap
  1027.                     pDC->LineTo(x + m_tabHeight - j        , y - 4 - j);                //
  1028.                 }
  1029.  
  1030.                 pDC->MoveTo(x + m_tabHeight - 2,     y - pTab->m_tabWidth + 3 + j);
  1031.                 pDC->LineTo(x + m_tabHeight - 4,     y - pTab->m_tabWidth + 1 + j);                    // 5
  1032.                 pDC->LineTo(x - 2 - j, y - pTab->m_tabWidth + 1 + j);    // 6
  1033.             }
  1034.             
  1035.             // Font
  1036.             pDC->SelectObject(m_boldFont);
  1037.         }
  1038.         else
  1039.         {
  1040.             // Outline
  1041.             BKPEN();
  1042.             pDC->MoveTo(x                        , y);
  1043.             pDC->LineTo(x + m_tabHeight - 4     , y);                            // 1
  1044.             pDC->LineTo(x + m_tabHeight            , y - 4);                        // 2
  1045.             pDC->LineTo(x + m_tabHeight            , y - pTab->m_tabWidth + 4);    // 3
  1046.             pDC->LineTo(x + m_tabHeight - 4        , y - pTab->m_tabWidth);        // 4
  1047.             pDC->LineTo(x                         , y - pTab->m_tabWidth);        // 5
  1048.         
  1049.             // Hilite
  1050.             DKPEN();
  1051.             pDC->MoveTo(x + 1                    , y - 1);
  1052.             pDC->LineTo(x + m_tabHeight - 5        , y - 1);                        // 1
  1053.             pDC->LineTo(x + m_tabHeight - 1        , y - 5);                        // 2
  1054.             LTPEN();
  1055.             pDC->LineTo(x + m_tabHeight - 1        , y - pTab->m_tabWidth + 5);      // 3
  1056.     
  1057.             // Shadow
  1058.             LTPEN();
  1059.             pDC->MoveTo(x + m_tabHeight - 2        , y - pTab->m_tabWidth + 3);
  1060.             pDC->LineTo(x + m_tabHeight - 4        , y - pTab->m_tabWidth + 1);      // 4
  1061.             pDC->LineTo(x                         , y - pTab->m_tabWidth + 1);    // 5
  1062.             
  1063.             // Font
  1064.             pDC->SelectObject(m_normalFont);
  1065.         }
  1066.  
  1067.         // DrawText inside clipping rect doesn't seem to work for vertical orientation.
  1068.         // TextOut takes the (x,y) coordinates given, and rotates the string about that point.
  1069.         // So for our 90 degree rotation, (x,y) becomes the bottom left.
  1070.         CSize size = pDC->GetTextExtent(pTab->m_tabLabel, strlen(pTab->m_tabLabel));
  1071.         int left = x + m_tabHeight - (m_tabHeight-size.cy)/2 + 1;
  1072.         int top  = y - pTab->m_tabWidth + (pTab->m_tabWidth - size.cx)/2;
  1073.         int oldMode = pDC->SetBkMode(TRANSPARENT);
  1074.  
  1075.         pDC->SetTextColor(GetSysColor(pTab->m_active ? COLOR_BTNTEXT:COLOR_GRAYTEXT));
  1076.         pDC->TextOut(left, top, pTab->m_tabLabel, strlen(pTab->m_tabLabel));
  1077.         pDC->SetBkMode(oldMode);
  1078.  
  1079.         if(m_position == TABSONRIGHT)
  1080.             y += pTab->m_tabWidth;
  1081.         else
  1082.             y -= pTab->m_tabWidth;
  1083.     }
  1084.     pDC->SetTextColor(oldTextColor);
  1085. }
  1086. /////////////////////////////////////////////////////////////////////////////
  1087. // CTabView diagnostics
  1088.  
  1089. #ifdef _DEBUG
  1090. void THIS::AssertValid() const
  1091. {
  1092.     BASE::AssertValid();
  1093. }
  1094.  
  1095. void THIS::Dump(CDumpContext& dc) const
  1096. {
  1097.     CView::Dump(dc);
  1098. }
  1099. #endif //_DEBUG
  1100.  
  1101.  
  1102. void THIS::OnSetFocus(CWnd* pOldWnd)
  1103. {
  1104.     CView::OnSetFocus(pOldWnd);
  1105.     
  1106.     if (m_curView)
  1107.     {
  1108.         // Set the keyboard focus to this view
  1109.         m_curView->SetFocus();
  1110.         GetParentFrame()->SetActiveView(m_curView);
  1111.         return;
  1112.     }
  1113.     
  1114. }
  1115.  
  1116. int THIS::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  1117. {
  1118.     return MA_ACTIVATE;
  1119. }
  1120.